<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>  
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>合同方案列表</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
	<input type="hidden" id="cfgCd" value="${cfgCd }">
	<div class="btnsBox">
		<span id="addBtn"  class="sq-button sq-button-round" onclick="toContSelect()">新增</span>
	</div>
	<div id="ligergrid" class="sq-grid"></div>
</div>

<script type="text/javascript">

    $(function () {
		initGrid();
    });


    function initGrid() {

		grid = $("#ligergrid").ligerGrid({
			url: '<%=path%>/cont/prj/initDtlList.do',
			method: 'get',
			parms:{cfgCd:$("#cfgCd").val()},
			columns: [
				{display: '合同编码', name: 'contCd'},
				{display: '合同名称', name: 'contNm'},
				{display: '合同描述', name: 'contDesc'},
				{display: '合同类型', name: 'contTypNm'},
				{display: '操作',
					render:function (rowdata, rowindex, value, column) {
						var h="";
						if(rowdata.isVal){
							h+="<a href='javascript:void(0)' onclick='showDialog(\""+rowdata.valRule+"\",\""+rowdata.contKv+"\")'>取值</a>";
							h+="<a class='sq-button-hasicon' href='javascript:void(0)' onclick='deleteCont(\""+rowdata.id+"\")'>删除</a>";
						}else{
							h+="<a href='javascript:void(0)' onclick='deleteCont(\""+rowdata.id+"\")'>删除</a>";
						}
						return h;
					}
				}
			],
			root: 'rows',
            record: 'total',
			height:400,
            rownumbers:true//列表是否有行号
		});
		//grid.setHeight(100);
	}

    
	function deleteCont(id) {
		
		$.ligerDialog.confirm('确定删除吗?', function (yes) {
			if(yes){
				var wait_dialog;
				$.ajax({
					type: 'post',
					dataType:'json',
					data:{id:id},
					url: '<%=path%>/cont/prj/delCont.do',
					beforeSend: function () {
						wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
					},
					success:function(msg){
						wait_dialog.close();
						if(msg.success == 1){
							top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
							grid.reload();
						}else{
							top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
						}
					},
					error:function () {
						wait_dialog.close();
						top.$.ligerDialog.SQalert({content: "系统错误，请稍后重试",SQ_type: "error"});
					}
				});
			}
		});
		
	}


	function toContSelect(){
		$.ligerDialog.open({
            height:600,
            width: 800,
            title : '选择合同',
            url: '<%=path%>/cont/prj/toContSelectPage.do', 
            showMax: false,
            showToggle: true,
            showMin: false,
            isResize: true,
            slide: false,
            data: {
                cfgCd: $("#cfgCd").val(),
                callback:function(){
                	grid.reload();
                }
            }
            //自定义参数
            //myDataName: $("#txtValue").val()
        });
	}
	
	function showDialog(ruleValue,contKv){
		var rtitle = "";
		if("zgshBcxy"==ruleValue){
			rtitle="ZGSH补充协议";
		}else if("zgshZlzfb"==ruleValue){
			rtitle="ZGSH租赁支付表";
		}else if("zgshMM"==ruleValue){
			rtitle="ZGSH买卖合同";
		}
		$.ligerDialog.open({
            height:350,
            width: 450,
            title : rtitle,
            url: '<%=path%>/cont/prj/toContKvPage.do?rule='+ruleValue, 
            showMax: false,
            showToggle: true,
            showMin: false,
            isResize: true,
            slide: false,
            data: {
            	mode:'show',
            	contKv:contKv
            }
            //自定义参数
            //myDataName: $("#txtValue").val()
        });
	}

    

</script>

</body>
</html>